//
//  MineVC.swift
//  Xiaozihui
//
//  Created by 校企荟 on 2017/8/21.
//  Copyright © 2017年 校企荟. All rights reserved.
//

import UIKit

let mineCellID = "mineCell"

class MineVC: BaseVC {

    lazy var tableView: BaseTableView = {
        let tv = BaseTableView()
        tv.dataSource = self
        tv.delegate = self
        tv.register(MineCell.self, forCellReuseIdentifier: mineCellID)
        tv.estimatedRowHeight = 200
        tv.rowHeight = UITableViewAutomaticDimension
        return tv
    }()
    
    lazy var header: MineHeader = {
        
        return MineHeader(frame: CGRect.zero)
    }()
    
    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
    
    override func setupUI() {
        
        view.addSubview(tableView)
        tableView.snp.makeConstraints { (make) in
            make.edges.equalTo(view)
        }
        tableView.tableHeaderView = header
        
        
        
        let btn = UIButton(type: .system)
        btn.setTitle("登出", for: .normal)
        view.addSubview(btn)
        btn.snp.makeConstraints { (make) in
            make.center.equalTo(view)
            make.width.height.equalTo(200)
        }
        btn.addTarget(self, action: #selector(logout), for: .touchUpInside)
    }

    func logout() {
        AccountManager.sharedManager.loginOut()
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}



extension MineVC : UITableViewDataSource,UITableViewDelegate {
    @available(iOS 2.0, *)
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: mineCellID, for: indexPath) as! MineCell
        return cell
    }

    @available(iOS 2.0, *)
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 3
    }


    
}
